﻿using System;
using System.Data;
using System.Linq;
using System.Windows;
using WPFExcelReport.Chart;
using System.Windows.Controls;
using WPFExcelReport.Helpers;
using System.ComponentModel;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class TSJHVKP
    {
        public TSJHVKP()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVKPOS();
            this.DataContext = MV;

            InitializeComponent();
            VKPSA = "  ";
        }
        public override void OnLOOMPROFITChg(double value)
        {            
            switch(app.company)
            {
              
                case "SJH":
                    SJHBONUS(value);
                    break;
                default:
                    break;
            }
            base.OnLOOMPROFITChg(value);
        }
        public override void OnBPRICEChg(double bprice)
        {
            //含税单价/1.17*1-贴息率）
            RAWPRICE = Helper.RoundX(bprice / 1.17 * (1 - RATEOST * 0.001 * 0.01), 10000);
            GRPROFIT = Helper.RoundX(RAWPRICE - MCOST * 0.0001, 10000);
            LOOMPROFIT = Helper.RoundX(DPROD * GRPROFIT, 1);
        }
        public override void CHKTSTPOSTYP(string aufart)
        {
            base.CHKTSTPOSTYP(aufart);
            //IsCheckVA = false;
        }
        public override void NewCommand(object sender, RoutedEventArgs e)
        {           
            base.NewCommand(sender, e);
        }
        public override void UPDATEVKP(DataRow _dwVKP)
        {
            //cNOVA.IsAuto = false;
            //cNOVA.IsAuto = true;
            base.UPDATEVKP(_dwVKP);
        }

        public void SJHBONUS(double value)
        {
            MYCOM = "";
            MYBON = "";
            if (VB == "NX ")
            {
                MYCOM = SACHBE.PadRight(8) + "0100";
            }
            else
            {
                MYCOM = SACHBE.PadRight(8) + "0200";
            }
            /*
             * 5.4.2 提成比例（B）
                利润
                （w元/台.天）	W ≤10	11＜W≤39	39＜W≤59	59＜W≤79	79＜W≤100	＞100
                内贸提成比例	0	1%	3%	4%	6%	8%
                外贸提成比例	0	0				


             */
            if (value <= 10)
            {
                MYBON = SACHBE.PadRight(8) + "0000";
            }
            else
            {
                if (value <= 39)
                {
                    if (VB == "NX ")
                    {
                        MYBON = SACHBE.PadRight(8) + "0100";
                    }
                    else
                    {
                        MYBON = SACHBE.PadRight(8) + "0000";
                    }

                }
                else
                {
                    if (value <= 59)
                    {

                        MYBON = SACHBE.PadRight(8) + "0300";
                    }
                    else
                    {
                        if (value <= 79)
                        {
                            MYBON = SACHBE.PadRight(8) + "0400";
                        }
                        else
                        {
                            if (value <= 100)
                            {
                                MYBON = SACHBE.PadRight(8) + "0600";
                            }
                            else
                            {
                                MYBON = SACHBE.PadRight(8) + "0800";
                            }
                        }
                    }
                }
            }

        }
    }
}
